let referrer = "";//登录后返回页面
referrer = document.referrer;
if (!referrer) {
    try {
        if (window.opener) {
            // IE下如果跨域则抛出权限异常，Safari和Chrome下window.opener.location没有任何属性
            referrer = window.opener.location.href;
        }
    } catch (e) {
    }
}

//按键盘Enter键即可登录
$(document).keyup(function (event) {
    if (event.keyCode == 13) {
        login();
    }
});

// jQuery(document).ready：页面文档结构加载完毕后执行
// onload:文档+内容加载完毕后执行
// jQuery(document).ready(function () {
//
// });

function Login() {
    let phone = $.trim($("#phone").val());
    let loginPassword = $.trim($("#loginPassword").val());
    //手机号为空
    if (phone == null || phone == "") {
        $("#phone").focus();
        return;
    }
    //密码为空
    if (loginPassword == null || loginPassword == "") {
        $("#loginPassword").focus();
        return;
    }
    //登录验证
    $.post("/web/loan/page/loginSubmit", {
        phone: phone,
        loginPassword: $.md5(loginPassword)
    }, function (data) {
        if (data.code == 1) {
            // window.location.href = "/web/index";
            window.location.href = $("#ReturnUrl").val();
        }
        if (data.code == 0) {
            alert(data.message);
            if (data.message == "请您实名认证后登录！") {
                window.location.href = "/web/loan/page/realName";
            }
        }
    });
}